<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/avatar.jpg">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-big-counter.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"raphets.github.io","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"hide","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"default"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="详细记录一下鸿蒙系统版本的微信登录开发，避免日后踩坑。">
<meta property="og:type" content="article">
<meta property="og:title" content="鸿蒙系统微信登录开发指南">
<meta property="og:url" content="https://raphets.github.io/archives/8113207a.html">
<meta property="og:site_name" content="尚拙">
<meta property="og:description" content="详细记录一下鸿蒙系统版本的微信登录开发，避免日后踩坑。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2025-05-21T08:57:04.000Z">
<meta property="article:modified_time" content="2025-05-21T12:06:20.183Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="鸿蒙">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://raphets.github.io/archives/8113207a.html">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>鸿蒙系统微信登录开发指南 | 尚拙</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">尚拙</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">一个分享技术、学习成长的个人博客网站</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-tool">

    <a href="/tool/" rel="section"><i class="fa fa-hammer fa-fw"></i>工具</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://raphets.github.io/archives/8113207a.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="John Doe">
      <meta itemprop="description" content="不积跬步，无以至千里；不积小流，无以成江海。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="尚拙">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          鸿蒙系统微信登录开发指南
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2025-05-21 16:57:04 / 修改时间：20:06:20" itemprop="dateCreated datePublished" datetime="2025-05-21T16:57:04+08:00">2025-05-21</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%8A%80%E6%9C%AF%E6%96%87%E7%AB%A0/" itemprop="url" rel="index"><span itemprop="name">技术文章</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%8A%80%E6%9C%AF%E6%96%87%E7%AB%A0/%E9%B8%BF%E8%92%99/" itemprop="url" rel="index"><span itemprop="name">鸿蒙</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>详细记录一下鸿蒙系统版本的微信登录开发，避免日后踩坑。</p>
<span id="more"></span>

<h1 id="一、微信后台添加应用并配置鸿蒙应用信息"><a href="#一、微信后台添加应用并配置鸿蒙应用信息" class="headerlink" title="一、微信后台添加应用并配置鸿蒙应用信息"></a>一、微信后台添加应用并配置鸿蒙应用信息</h1><p>首先要在微信开放平台（<a target="_blank" rel="noopener" href="https://open.weixin.qq.com)添加应用,配置鸿蒙应用信息并审核通过./">https://open.weixin.qq.com）添加应用，配置鸿蒙应用信息并审核通过。</a></p>
<p>Bundle ID：指的是鸿蒙应用的包名</p>
<p>Identifier：指的是鸿蒙应用的 appIdentifier</p>
<p><strong>获取方法一：华为应用后台获取</strong></p>
<p>华为应用管理 —&gt; 我的项目 —&gt; 项目设置 —&gt; OAuth 2.0客户端ID —&gt; Client ID</p>
<p>Client ID 就是鸿蒙应用的 appIdentifier</p>
<p><strong>获取方法二：代码获取</strong></p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO).then((info) =&gt; &#123;</span><br><span class="line">    let appIdentifier = info.signatureInfo.appIdentifier</span><br><span class="line">    LogUtil.debug(&quot;[EntryAbility]appIdentifier：&quot; + appIdentifier)</span><br><span class="line">  &#125;)</span><br></pre></td></tr></table></figure>


<h1 id="二、引入微信SDK"><a href="#二、引入微信SDK" class="headerlink" title="二、引入微信SDK"></a>二、引入微信SDK</h1><p>在项目级或者应用级的oh-package.json5文件中的dependencies增加微信sdk库，注意修改sdk最新的版本号</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">&quot;dependencies&quot;: &#123;</span><br><span class="line">    &quot;@tencent/wechat_open_sdk&quot;: &quot;1.0.14&quot;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<h1 id="三、增加微信SDK回调类"><a href="#三、增加微信SDK回调类" class="headerlink" title="三、增加微信SDK回调类"></a>三、增加微信SDK回调类</h1><p>新建文件WXApiWrap.ets,代码如下</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">import * as wxopensdk from &#x27;@tencent/wechat_open_sdk&#x27;;</span><br><span class="line">import &#123; LogUtil &#125; from &#x27;../utils/LogUtil&#x27;;</span><br><span class="line"></span><br><span class="line">export type OnWXReq = (req: wxopensdk.BaseReq) =&gt; void</span><br><span class="line">export type OnWXResp = (resp: wxopensdk.BaseResp) =&gt; void</span><br><span class="line"></span><br><span class="line">const kTag = &quot;WXApiEventHandlerImpl&quot;</span><br><span class="line"></span><br><span class="line">class WXApiEventHandlerImpl implements wxopensdk.WXApiEventHandler &#123;</span><br><span class="line">  private onReqCallbacks: Map&lt;OnWXReq, OnWXReq&gt; = new Map</span><br><span class="line">  private onRespCallbacks: Map&lt;OnWXResp, OnWXResp&gt; = new Map</span><br><span class="line"></span><br><span class="line">  registerOnWXReqCallback(on: OnWXReq) &#123;</span><br><span class="line">    this.onReqCallbacks.set(on, on)</span><br><span class="line">  &#125;</span><br><span class="line">  unregisterOnWXReqCallback(on: OnWXReq) &#123;</span><br><span class="line">    this.onReqCallbacks.delete(on)</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  registerOnWXRespCallback(on: OnWXResp) &#123;</span><br><span class="line">    this.onRespCallbacks.set(on, on)</span><br><span class="line">  &#125;</span><br><span class="line">  unregisterOnWXRespCallback(on: OnWXResp) &#123;</span><br><span class="line">    this.onRespCallbacks.delete(on)</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  onReq(req: wxopensdk.BaseReq): void &#123;</span><br><span class="line">    wxopensdk.Log.i(kTag, &quot;onReq:%s&quot;, JSON.stringify(req))</span><br><span class="line">    LogUtil.debug(&quot;[WXApiEventHandlerImpl]onReq&quot;,JSON.stringify(req))</span><br><span class="line">    this.onReqCallbacks.forEach((on) =&gt; &#123;</span><br><span class="line">      on(req)</span><br><span class="line">    &#125;)</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  onResp(resp: wxopensdk.BaseResp): void &#123;</span><br><span class="line">    wxopensdk.Log.i(kTag, &quot;onResp:%s&quot;, JSON.stringify(resp))</span><br><span class="line">    LogUtil.debug(&quot;[WXApiEventHandlerImpl]onResp&quot;,JSON.stringify(resp))</span><br><span class="line">    this.onRespCallbacks.forEach((on) =&gt; &#123;</span><br><span class="line">      on(resp)</span><br><span class="line">    &#125;)</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">export const WXApi = wxopensdk.WXAPIFactory.createWXAPI(&quot;填写微信后台移动应用的APPID&quot;)</span><br><span class="line">export const WXEventHandler = new WXApiEventHandlerImpl</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h1 id="四、在EntryAbility中响应来自微信的回调"><a href="#四、在EntryAbility中响应来自微信的回调" class="headerlink" title="四、在EntryAbility中响应来自微信的回调"></a>四、在EntryAbility中响应来自微信的回调</h1><p>在应用启动类EntryAbility.ets中添加如下代码：</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">export default class EntryAbility extends UIAbility &#123;</span><br><span class="line">  onCreate(want: Want, _launchParam: AbilityConstant.LaunchParam): void &#123;</span><br><span class="line">    this.handleWeChatCallIfNeed(want)</span><br><span class="line">  &#125;</span><br><span class="line">  </span><br><span class="line">  onNewWant(want: Want, _launchParam: AbilityConstant.LaunchParam): void &#123;</span><br><span class="line">    this.handleWeChatCallIfNeed(want)</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  private handleWeChatCallIfNeed(want: Want) &#123;</span><br><span class="line">    WXApi.handleWant(want, WXEventHandler)</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>主要是添加handleWeChatCallIfNeed函数，然后在EntryAbility的onCreate和onNewWant生命周期中调用该函数</p>
<h1 id="五、发起微信登录"><a href="#五、发起微信登录" class="headerlink" title="五、发起微信登录"></a>五、发起微信登录</h1><h4 id="1、定义微信wxApi、wxEventHandler对象和OnWXResp回调"><a href="#1、定义微信wxApi、wxEventHandler对象和OnWXResp回调" class="headerlink" title="1、定义微信wxApi、wxEventHandler对象和OnWXResp回调"></a>1、定义微信wxApi、wxEventHandler对象和OnWXResp回调</h4><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">private wxApi = WXApi</span><br><span class="line">private wxEventHandler = WXEventHandler</span><br><span class="line">@State authResultText: string = &#x27;&#x27;</span><br><span class="line">private onWXResp: OnWXResp = (resp) =&gt; &#123;</span><br><span class="line">  this.authResultText = JSON.stringify(resp ?? &#123;&#125;, null, 2)</span><br><span class="line">  LogUtil.debug(&quot;wechat login result : &quot; + this.authResultText)</span><br><span class="line">  if(resp[&quot;errCode&quot;] !== 0)&#123;</span><br><span class="line">    promptAction.showToast(&#123;</span><br><span class="line">      message: resp[&quot;errStr&quot;],</span><br><span class="line">      duration: 3000</span><br><span class="line">    &#125;)</span><br><span class="line">  &#125;else &#123;</span><br><span class="line">    this.getWechatInfo(resp[&quot;code&quot;])</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="2、注册微信登录回调"><a href="#2、注册微信登录回调" class="headerlink" title="2、注册微信登录回调"></a>2、注册微信登录回调</h4><p>在aboutToAppear生命周期中注册微信登录回调，在aboutToDisappear生命周期中销毁微信登录回调</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">aboutToAppear(): void &#123;</span><br><span class="line">  this.wxEventHandler.registerOnWXRespCallback(this.onWXResp)</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">aboutToDisappear(): void &#123;</span><br><span class="line">  this.wxEventHandler.unregisterOnWXRespCallback(this.onWXResp)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="3、启动微信登录"><a href="#3、启动微信登录" class="headerlink" title="3、启动微信登录"></a>3、启动微信登录</h4><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">let req = new wxopensdk.SendAuthReq</span><br><span class="line">    req.isOption1 = false</span><br><span class="line">    req.nonAutomatic = true</span><br><span class="line">    req.scope = &#x27;snsapi_userinfo&#x27;</span><br><span class="line">    req.state = &#x27;none&#x27;</span><br><span class="line">    req.transaction = &#x27;test123&#x27;</span><br><span class="line"></span><br><span class="line">    let finished = await this.wxApi.sendReq(getContext(this) as common.UIAbilityContext, req)</span><br><span class="line">    LogUtil.debug(&quot;wechat login send request finished:&quot; + finished)</span><br></pre></td></tr></table></figure>

<h4 id="4、请求接口获取openid"><a href="#4、请求接口获取openid" class="headerlink" title="4、请求接口获取openid"></a>4、请求接口获取openid</h4><p>根据微信登录回调中的code，请求微信接口获取openid和unionid</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">async getWechatInfo(code:string)&#123;</span><br><span class="line">   let dto = await efRcpClientApi.get&lt;string&gt;(&#123;</span><br><span class="line">     url: `https://api.weixin.qq.com/sns/oauth2/access_token?appid=$&#123;WechatConstants.APPID&#125;&amp;secret=$&#123;WechatConstants.APP_SECRET&#125;&amp;code=$&#123;code&#125;&amp;grant_type=authorization_code`</span><br><span class="line">   &#125;);</span><br><span class="line">   if(dto.data)&#123;</span><br><span class="line">     LogUtil.debug(&quot;getWechatInfo:&quot; + JSON.stringify(dto.data))</span><br><span class="line">     let unionid:string = dto.data[&quot;unionid&quot;]</span><br><span class="line">     let openid:string = dto.data[&quot;openid&quot;]</span><br><span class="line">     this.thirdLogin(&quot;wechat&quot;,unionid)</span><br><span class="line">   &#125;else &#123;</span><br><span class="line">     promptAction.showToast(&#123;</span><br><span class="line">       message: &quot;微信登录异常，请稍后重试&quot;,</span><br><span class="line">       duration: 3000</span><br><span class="line">     &#125;)</span><br><span class="line">   &#125;</span><br><span class="line"></span><br><span class="line"> &#125;</span><br></pre></td></tr></table></figure>
    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E9%B8%BF%E8%92%99/" rel="tag"><i class="fa fa-tag"></i> 鸿蒙</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/archives/5dbc44b9.html" rel="prev" title="如何在本地调用魔塔社区的大模型">
      <i class="fa fa-chevron-left"></i> 如何在本地调用魔塔社区的大模型
    </a></div>
      <div class="post-nav-item">
    <a href="/archives/8113207a.html" rel="next" title="鸿蒙系统微信登录开发指南">
      鸿蒙系统微信登录开发指南 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E5%BE%AE%E4%BF%A1%E5%90%8E%E5%8F%B0%E6%B7%BB%E5%8A%A0%E5%BA%94%E7%94%A8%E5%B9%B6%E9%85%8D%E7%BD%AE%E9%B8%BF%E8%92%99%E5%BA%94%E7%94%A8%E4%BF%A1%E6%81%AF"><span class="nav-number">1.</span> <span class="nav-text">一、微信后台添加应用并配置鸿蒙应用信息</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E5%BC%95%E5%85%A5%E5%BE%AE%E4%BF%A1SDK"><span class="nav-number">2.</span> <span class="nav-text">二、引入微信SDK</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E5%A2%9E%E5%8A%A0%E5%BE%AE%E4%BF%A1SDK%E5%9B%9E%E8%B0%83%E7%B1%BB"><span class="nav-number">3.</span> <span class="nav-text">三、增加微信SDK回调类</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81%E5%9C%A8EntryAbility%E4%B8%AD%E5%93%8D%E5%BA%94%E6%9D%A5%E8%87%AA%E5%BE%AE%E4%BF%A1%E7%9A%84%E5%9B%9E%E8%B0%83"><span class="nav-number">4.</span> <span class="nav-text">四、在EntryAbility中响应来自微信的回调</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%94%E3%80%81%E5%8F%91%E8%B5%B7%E5%BE%AE%E4%BF%A1%E7%99%BB%E5%BD%95"><span class="nav-number">5.</span> <span class="nav-text">五、发起微信登录</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1%E3%80%81%E5%AE%9A%E4%B9%89%E5%BE%AE%E4%BF%A1wxApi%E3%80%81wxEventHandler%E5%AF%B9%E8%B1%A1%E5%92%8COnWXResp%E5%9B%9E%E8%B0%83"><span class="nav-number">5.0.0.1.</span> <span class="nav-text">1、定义微信wxApi、wxEventHandler对象和OnWXResp回调</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2%E3%80%81%E6%B3%A8%E5%86%8C%E5%BE%AE%E4%BF%A1%E7%99%BB%E5%BD%95%E5%9B%9E%E8%B0%83"><span class="nav-number">5.0.0.2.</span> <span class="nav-text">2、注册微信登录回调</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3%E3%80%81%E5%90%AF%E5%8A%A8%E5%BE%AE%E4%BF%A1%E7%99%BB%E5%BD%95"><span class="nav-number">5.0.0.3.</span> <span class="nav-text">3、启动微信登录</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4%E3%80%81%E8%AF%B7%E6%B1%82%E6%8E%A5%E5%8F%A3%E8%8E%B7%E5%8F%96openid"><span class="nav-number">5.0.0.4.</span> <span class="nav-text">4、请求接口获取openid</span></a></li></ol></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="John Doe"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">John Doe</p>
  <div class="site-description" itemprop="description">不积跬步，无以至千里；不积小流，无以成江海。</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">47</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">32</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2025</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">John Doe</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
